package cloud.gateway.config;


import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 通过Java方式配置路由规则
 */
@Configuration
public class GateConfig {

    @Bean
    public RouteLocator routeLocator(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder routers = builder.routes();
        routers.route("path_router_luoqiu", r -> r.path("/guonei").uri("http://news.baidu.com/guonei")).build();
        return routers.build();
    }

}
